<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 更新版本信息</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">

		<div class="col-sm-12">
			<div class="ibox float-e-margins">
			    <div class="ibox-content">
			        <form class="form-horizontal m-t" id="commentForm" novalidate="novalidate">
			            <div class="form-group">
			                <label class="col-sm-3 control-label">版本名称：</label>
			                <div class="col-sm-8">
			                    <input id="name" name="name" minlength="2" type="text" class="form-control" required="" aria-required="true" value="{$up.name}">
			                </div>
			            </div>
			            <input type="hidden" name="id" value="{$up.id}">
			            <div class="form-group">
			                <label class="col-sm-3 control-label">版本介绍：</label>
			                <div class="col-sm-8">
			                    <input id="describes" type="text" class="form-control" name="describes" required="" aria-required="true" value="{$up.describes}">
			               </div>
			            </div>
			            <div class="form-group">
			                <label class="col-sm-3 control-label">是否免费：</label>
			                <div class="col-sm-8">
			                    <div class="radio radio-info radio-inline">
                                    <input type="radio" id="inlineRadio1" value="1" name="free" {if condition="$up['free'] eq 1"} checked="checked" {/if}>
                                    <label for="inlineRadio1"> 是 </label>
                                </div>
                                <div class="radio radio-info  radio-inline">
                                    <input type="radio" id="inlineRadio2" value="0" name="free" {if condition="$up['free'] eq 0"} checked="checked" {/if}>
                                    <label for="inlineRadio2"> 否 </label>
                                </div>
			                </div>
			            </div>
			            <div class="form-group">
			                <label class="col-sm-3 control-label">价格：</label>
			                <div class="col-sm-8">
			                    <input  type="text" class="form-control" name="price" value="{$up.price}" >
			               </div>
			            </div>
			            <div class="form-group ">
			                <label class="col-sm-3 control-label">版本号：</label>
			                <div class="col-sm-8">
			                    <input id="vision" type="text" class="form-control" name="vision" required="" aria-required="true" value="{$up.vision}" >
			                </div>
			            </div>
			            <div class="form-group">
			                <label class="col-sm-3 control-label">小程序模版ID：</label>
			                <div class="col-sm-8">
			                    <input id="smapp_template_id" type="text" class="form-control" name="smapp_template_id" required="" aria-required="true" value="{$up.smapp_template_id}">
			                </div>
			            </div>
			            <div class="form-group">
			                <div class="col-sm-4 col-sm-offset-3">
			                    <button class="btn btn-primary" type="button" id="onbtn">提交</button>
			                </div>
			            </div>
			        </form>
			    </div>
			</div>
		</div>
	</div>
</div>
    <!-- 全局js -->
    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script src="{$Think.config.site.resource_url}js/content.js?v=1.0.0"></script>
    <!-- jQuery Validation plugin javascript-->
    <script src="{$Think.config.site.resource_url}js/plugins/validate/jquery.validate.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/messages_zh.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/demo/form-validate-demo.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
	<script type="text/javascript">
		$('#onbtn').click(function(){
			var formdata = $('#commentForm').serialize();
			var name = $('#name').val();
			var describes = $('#describes').val();
			var vision = $('#vision').val();
			var tid = $('#smapp_template_id').val();
			if(name==''){
				$("#name").attr('placeholder','请输入版本名称');
			    $("#name").focus();
			    return false;
			}
			if(describes==''){
				$("#describes").attr('placeholder','请输入版本介绍');
			    $("#describes").focus();
			    return false;
			}
			if(vision==''){
				$("#vision").attr('placeholder','请输入版本号ID');
			    $("#vision").focus();
			    return false;
			}
			if(tid==''){
				$("#smapp_template_id").attr('placeholder','请输入模版ID');
			    $("#smapp_template_id").focus();
			    return false;
			}
			$.ajax({
                type : 'POST',
                url  : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/System/version',
                dataType : 'json',
                data : formdata,
                async : false,
                success : function(result){
                    if(0 == result.code){
                        layer.msg(result.msg, {icon: 1});
                        parent.location.reload();
                    }else{
                        layer.msg(result.msg, {icon: 5});
                    }
                },
                error : function(){
                    layer.msg('服务器错误！请稍后重试', {icon: 2});
                }
            });	
		});
	</script>
</body>
</html>